﻿using System;
using Cysharp.Threading.Tasks;
using QFramework;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;


public class UIGameOver: MonoBehaviour,IController
{
    public IArchitecture GetArchitecture() => GameArchitecture.Interface;
    public Button m_Button;
    public Button RestartButton;
    public Text m_Text;
    public string audioPath;
    public void Awake()
    {
        m_Button.onClick.AddListener(OnButtonClick);
        RestartButton?.onClick.AddListener(ReStart);
        var audioSystem = this.GetSystem<AudioSystem>();
        audioSystem.StopAllSound();
    }
    

    public void OnButtonClick()
    {
        Debug.Log("reset Game");
        Restart().Forget();
    }
    private async UniTaskVoid Restart()
    {
        var audioSystem = this.GetSystem<AudioSystem>();
        // audioSystem.StopAllSound();
        audioSystem.PlaySoundEffect("Sound/effects/button04b");
        await this.GetSystem<UIManager>().OpenUIPanel("UIPanel/UIChooseStage/UIChooseStage");
        // SceneManager.LoadScene("StartScene");
        
   
    }
    private async void ReStart()
    {
        await SceneManager.LoadSceneAsync("GameScene");
    }
}
